#include <iostream>
#include <ctime>
#include "DenseGraph.h"
#include "SparseGraph.h"

int main() {
    int N = 10;
    int M = 30;

    srand(time(NULL));

    // Sparse Graph
    // 存在平行边
    SparseGraph g1(N, false);
    for(int i = 0; i < M; ++i){
        int a = rand() % N;
        int b = rand() % N;
        g1.addEdge(a, b);
    }
    // O(E)
    for(int v = 0; v < N; ++v){
        cout << v << " : ";
        SparseGraph::adjIterator adj(g1, v);
        for(int w = adj.begin(); !adj.end(); w = adj.next()){
            cout << w << " ";
        }
        cout << endl;
    }
    cout << endl;
    // Dense Graph
    // 存在自环边
    DenseGraph g2(N, false);
    for(int i = 0; i < M; ++i){
        int a = rand() % N;
        int b = rand() % N;
        g2.addEdge(a, b);
    }
    // O(V^2)
    for(int v = 0; v < N; ++v){
        cout << v << " : ";
        DenseGraph::adjIterator adj(g2, v);
        for(int w = adj.begin(); !adj.end(); w = adj.next()){
            cout << w << " ";
        }
        cout << endl;
    }
}